import type { TableProps } from "tdesign-vue-next";

import dayjs from "dayjs";
import { getValueBySelectData, newPrecision } from "@/utils/tools";

import { CURRENCY_LIST, REPAY_STATUS_LIST } from "@/common/constants";

export const tableColumns = [
  {
    colKey: "amount",
    title: "账单金额",
    width: 200,
    cell: (h, { row }) => {
      return newPrecision(row.amount, 2);
    }
  },
  {
    colKey: "moneyUnit",
    title: "货币单位",
    width: 150,
    cell: (h, { row }) => {
      return getValueBySelectData(CURRENCY_LIST, row.moneyUnit);
    }
  },
  {
    colKey: "exchangeRate",
    title: "当时汇率",
    width: 220,
    cell: (h, { row }) => {
      return newPrecision(row.exchangeRate, 2);
    }
  },
  {
    colKey: "orderNo",
    title: "订单编号",
    width: 220
  },
  {
    colKey: "orderName",
    title: "订单名称",
    width: 220
  },
  {
    colKey: "customerName",
    title: "客户名称",
    width: 220
  },
  {
    colKey: "expireTime",
    title: "过期时间",
    width: 220,
    cell: (h, { row }) => {
      return dayjs(row.expireTime).format("YYYY-MM-DD");
    }
  },
  {
    colKey: "paidMoney",
    title: "已经还款金额",
    width: 200,
    cell: (h, { row }) => {
      return newPrecision(row.paidMoney, 2);
    }
  },
  {
    colKey: "paidStatus",
    title: "还款状态",
    width: 200,
    cell: (h, { row }) => {
      return getValueBySelectData(REPAY_STATUS_LIST, row.paidStatus);
    }
  }
] as TableProps["columns"];
